import axios from 'axios';
// import { config } from 'vue/types/umd';
axios.defaults.baseURL = "https://api.it120.cc/xiaochengxu"

axios.interceptors.request.use(config => {
    return config;
}, error => {
    return Promise.reject(error);
})

axios.interceptors.response.use(response => {
    return response.data;
}, error => {
    return Promise.reject(error);
})

export const get = ((url, data) => {
    return new Promise((resolve, reject) => {
        axios.get(url, data).then((res) => {
            resolve(res)
        }, err => {
            reject(err)
        })
    })
})

export const post = (url, data = {}) => {
    return new Promise((resolve, reject) => {
        axios.post(url, data).then(res => {
            resolve(res)
        }, err => {
            reject(err)
        })
    })
}